import 'package:equatable/equatable.dart';
import 'package:backend.core/core/domain/entities/api/web/api_web_purchased_subscription_status.dart';

const kApiWebPurchasedSubscriptionActiveStatusValue = 'active';
const kApiWebPurchasedSubscriptionExpiredStatusValue = 'expired';
const kApiWebPurchasedSubscriptionRevokedStatusValue = 'revoked';

class ApiWebPurchasedSubscriptionStatusDto extends Equatable {
  const ApiWebPurchasedSubscriptionStatusDto._internal({
    required this.statusString,
  });

  final String statusString;

  @override
  List<Object?> get props {
    return [
      statusString,
    ];
  }

  factory ApiWebPurchasedSubscriptionStatusDto.fromEntity(
      ApiWebPurchasedSubscriptionStatus status) {
    late final String statusString;

    if (status == ApiWebPurchasedSubscriptionStatus.active) {
      statusString = kApiWebPurchasedSubscriptionActiveStatusValue;
    } else if (status == ApiWebPurchasedSubscriptionStatus.expired) {
      statusString = kApiWebPurchasedSubscriptionExpiredStatusValue;
    } else if (status == ApiWebPurchasedSubscriptionStatus.revoked) {
      statusString = kApiWebPurchasedSubscriptionRevokedStatusValue;
    }

    return ApiWebPurchasedSubscriptionStatusDto._internal(
      statusString: statusString,
    );
  }

  @override
  String toString() {
    return statusString;
  }
}
